<html>
    <input id=foo type=checkbox>
    <label for=foo>This is a checkbox</label>
    <pre id=bar></pre>
    <script>
        var foo = document.getElementById("foo");
        var bar = document.getElementById("bar");
        foo.addEventListener("change", function() {
            bar.innerHTML += foo.checked + "\n";
        });
    </script>
</html>
